<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('teams', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->softDeletes();
            $table->foreignId('domain_id');
            $table->string('name');
            $table->string('description')->nullable();
            $table->dateTime('archived_at')->nullable();
        });

        //TODO: Нужно что бы связи дропались вместе  с уничтожением команды
        Schema::create('team_user', function (Blueprint $table) {
            $table->timestamps();
            $table->foreignId('user_id');
            $table->foreignId('team_id');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('teams');
        Schema::dropIfExists('user_team');
    }
};
